package com.nakamachizu.model.mixi;

import java.io.Serializable;
import java.util.Date;

import com.google.appengine.api.datastore.Key;
import com.nakamachizu.model.session.MixiFriendSession;
import com.nakamachizu.util.NakamachizuStringUtil;

import org.slim3.datastore.Attribute;
import org.slim3.datastore.Model;
import org.slim3.datastore.ModelRef;

@Model(schemaVersion = 1)
public class FriendMapModel implements Serializable {

    private static final long serialVersionUID = 1L;

    @Attribute(primaryKey = true)
    private Key key;

    @Attribute(version = true)
    private Long version;
    
    private String accessKey;
    
    private String mixiId;
    
    private String displayName;
    
    private String title;
    
    private String accessLevel;
    
    private Date expire;
    
    private int people;

    private ModelRef<MixiFriendSession>mixiFriendSessionRef = new ModelRef<MixiFriendSession>(MixiFriendSession.class);
    /**
     * Returns the key.
     *
     * @return the key
     */
    public Key getKey() {
        return key;
    }

    /**
     * Sets the key.
     *
     * @param key
     *            the key
     */
    public void setKey(Key key) {
        this.key = key;
    }

    /**
     * Returns the version.
     *
     * @return the version
     */
    public Long getVersion() {
        return version;
    }

    /**
     * Sets the version.
     *
     * @param version
     *            the version
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((key == null) ? 0 : key.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        FriendMapModel other = (FriendMapModel) obj;
        if (key == null) {
            if (other.key != null) {
                return false;
            }
        } else if (!key.equals(other.key)) {
            return false;
        }
        return true;
    }

    public String getAccessKey() {
        return accessKey;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public String getMixiId() {
        return NakamachizuStringUtil.mixiIdToNumeric(mixiId);
    }

    public void setMixiId(String mixiId) {
        this.mixiId = mixiId;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAccessLevel() {
        return accessLevel;
    }

    public void setAccessLevel(String accessLevel) {
        this.accessLevel = accessLevel;
    }

    public void setExpire(Date expire) {
        this.expire = expire;
    }

    public Date getExpire() {
        return expire;
    }

    public ModelRef<MixiFriendSession> getMixiFriendSessionRef() {
        return mixiFriendSessionRef;
    }

    public void setPeople(int people) {
        this.people = people;
    }

    public int getPeople() {
        return people;
    }
}
